package com.bolt.admin.module.sys.repository;


import com.bolt.admin.module.sys.entity.MenuEntity;
import com.bolt.support.spring.jpa.repository.BasicJpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author michao
 * Created by Administrator on 2017/9/28.
 */
public interface MenuRepository extends BasicJpaRepository<MenuEntity, Long> {

    @Query("from MenuEntity where childrenSize=0  order by orderRank ")
    List<MenuEntity> findAllChildrenMenu();

    @Query("from MenuEntity where id in (:menuIds)  order by orderRank ")
    List<MenuEntity> findAllByIds(@Param("menuIds") Long[] menuIds);

    /**
     * 根据菜单的 PID 查询
     * @param pid /
     * @return /
     */
    List<MenuEntity> findByPid(long pid);

    /**
     * 查询顶级菜单
     * @return /
     */
    List<MenuEntity> findByPidIsNull();



}
